package com.sinothk.software.ui.base;

import com.sinothk.software.utils.XUtils;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.colors.RgbColor;
import ohos.agp.components.element.ShapeElement;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

public class BaseAbilitySlice extends AbilitySlice {

    protected ShapeElement bg_root_view = null;

    @Override
    protected void onStart(Intent intent) {
        super.onStart(intent);

        // 设置背景色和渐变(从下端角到上端角)
        bg_root_view = new ShapeElement();
        bg_root_view.setShape(ShapeElement.RECTANGLE);
        RgbColor[] rgbColors = new RgbColor[]{new RgbColor(0, 133, 234), new RgbColor(0, 201, 169)};
        bg_root_view.setRgbColors(rgbColors);
        bg_root_view.setGradientOrientation(ShapeElement.Orientation.BOTTOM_END_TO_TOP_START);

        EventBus.getDefault().register(this);
    }

    @Override
    protected void onStop() {
        super.onStop();
        EventBus.getDefault().unregister(this);
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void eventBusCallback(String result) {
//        if (!"result.getEventType()".equals(result.getEventType())) {
//            return;
//        }
//
//        XUtils.toast().show(result.getMsg());
//        when (result.code) {
//            NetResult.SUCCESS -> {
//                if (result.data != null) {
//                } else {
//                    XUtils.toast().show("查无结果")
//                }
//            }
//            else -> {
//                XUtils.toast().show(result.msg)
//            }
//        }
    }
}
